package org.dey.controller;

import org.dey.entity.Result;
import org.dey.pojo.ArgetManagement;
import org.dey.pojo.PageVo;
import org.dey.service.ArgetManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class ArgetManagementController {

    @Autowired
    ArgetManagementService argetManagementService;

    @GetMapping("amid.do/{amid}")
    public ArgetManagement queryAmById(@PathVariable Integer amid) {
        ArgetManagement amById = argetManagementService.queryAmById(amid);
        return amById;
    }

    @PostMapping("addam.do")
    public Map addAm(@RequestBody ArgetManagement argetManagement) {
        System.out.println(argetManagement);
        return argetManagementService.addAm(argetManagement);
    }

    @DeleteMapping("delam.action/{amid}")
    public Result deleteAm(@PathVariable int amid) {
        Result result = argetManagementService.deleteAm(amid);
        return result;
    }


    @PutMapping("updateam.action")
    public int updateAm(@RequestBody ArgetManagement argetManagement) {
        return argetManagementService.updateAm(argetManagement);
    }

    @PostMapping("queryAm.do/{pageNum}/{pagesize}")
    public PageVo<ArgetManagement> queryAm(@RequestBody ArgetManagement argetManagement,
                                           @PathVariable Integer pageNum,
                                           @PathVariable Integer pagesize){
        PageVo<ArgetManagement> list = argetManagementService.queryAm(argetManagement, pageNum, pagesize);
        return list;
    }
}
